package com.comdo.newup_loan.module.repayment;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.comdo.newup_loan.R;
import com.comdo.newup_loan.base.BaseActivity;
import com.comdo.newup_loan.comom.Config;
import com.comdo.newup_loan.comom.GlideImageLoader;
import com.comdo.newup_loan.model.CostBean;
import com.comdo.newup_loan.util.StringUtils;
import com.comdo.newup_loan.util.TitleMenuUtil;

import butterknife.BindView;

/**
 * Created by liyuan on 2017/11/3.
 */

public class CostListActivity extends BaseActivity<CostListPersenter> implements CostListContact.View {
    @BindView(R.id.img_icon)
    ImageView userImageView;
    @BindView(R.id.tv_borrow_name)
    TextView mNameTextView;
    @BindView(R.id.tv_borrow_amount)
    TextView mAmountTextView;
    @BindView(R.id.tv_borrow_time)
    TextView mTimeTextView;
    @BindView(R.id.tv_borrow_date)
    TextView mDateTextView;
    @BindView(R.id.tv_totalcost)
    TextView mTotalTextView;

    @BindView(R.id.tv_sqdj) TextView sqdjText;
    @BindView(R.id.tv_glf) TextView glfText;
    @BindView(R.id.tv_fxj) TextView fxjText;
    @BindView(R.id.tv_fwf) TextView fwfjText;
    @BindView(R.id.tv_borrow_bzj) TextView bzjText;
    @BindView(R.id.tv_bxyj) TextView bxyjText;
    @BindView(R.id.tv_wzyj) TextView wzyjText;
    @BindView(R.id.tv_ycyj) TextView ycyjText;
    @BindView(R.id.tv_jszyj) TextView jszyjText;
    @BindView(R.id.tv_tcf) TextView tcfText;
    @BindView(R.id.tv_vip) TextView vipText;
    @BindView(R.id.tv_gpsyj) TextView gpsyjText;
    @BindView(R.id.tv_gpszjf) TextView gpszjfText;
    @BindView(R.id.tv_tx) TextView txText;
    @BindView(R.id.tv_dydj) TextView dydjText;
    @Override
    protected int getContentViewLayoutID() {
        return R.layout.activity_feed_list;
    }

    @Override
    protected void init() {
        super.init();
        mPresenter.getList(getIntent().getIntExtra("tenderId", 0), Config.loginInfo.getUserId());
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        new TitleMenuUtil(CostListActivity.this, "费用清单", true);
    }

    @Override
    public CostListPersenter getmPresenter() {
        return new CostListPersenter();
    }

    @Override
    public void presenterSetView() {
        if (mPresenter != null)
            mPresenter.setView(this);
    }

    @Override
    public void getFail(String failMessage) {
        showToast(failMessage);
    }

    @Override
    public void getList(CostBean datas) {
        initDatas(datas);
    }

    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
    }

    private void initDatas(CostBean datas) {
        mTotalTextView.setText(datas.getCost().toString());
        new GlideImageLoader().displayImage(CostListActivity.this,Config.PIC_FORE+datas.getPortrait(), userImageView);
        mNameTextView.setText(datas.getName());
        mAmountTextView.setText(StringUtils.getMoneyString(datas.getBorrowAmount()));
        mTimeTextView.setText(datas.getBorrowTimeTypes() + "");
        mDateTextView.setText(datas.getLoanTime());

        sqdjText.setText(StringUtils.getMoneyString(datas.getCost().getInterestCost()));
        glfText.setText(StringUtils.getMoneyString(datas.getCost().getManageCost()));
        fxjText.setText(StringUtils.getMoneyString(datas.getCost().getRiskCost()));
        fwfjText.setText(StringUtils.getMoneyString(datas.getCost().getServiceCost()));
        bzjText.setText(StringUtils.getMoneyString(datas.getCost().getSubmitCost()));
        bxyjText.setText(StringUtils.getMoneyString(datas.getCost().getSafeCost()));
        wzyjText.setText(StringUtils.getMoneyString(datas.getCost().getIllegalCost()));
        ycyjText.setText(StringUtils.getMoneyString(datas.getCost().getKeyCost()));
        jszyjText.setText(StringUtils.getMoneyString(datas.getCost().getDrivingCost()));
        tcfText.setText(StringUtils.getMoneyString(datas.getCost().getCarStopCost()));
        vipText.setText(StringUtils.getMoneyString(datas.getCost().getVipRegisteCost()));
        gpsyjText.setText(StringUtils.getMoneyString(datas.getCost().getGpsCost()));
        gpszjfText.setText(StringUtils.getMoneyString(datas.getCost().getGpsDeprecitionCost()));
        txText.setText(StringUtils.getMoneyString(datas.getCost().getWithdrawCost()));
        dydjText.setText(StringUtils.getMoneyString(datas.getCost().getMortgageCost()));
    }
}
